package org.lanqiao.api.collect;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.service.CartServiceImpl;
import org.lanqiao.service.CollectServieImpI;

import com.sun.net.httpserver.HttpServer;

@WebServlet("/api/collect/delete")
public class DeleteCollectServlet extends HttpServlet {
	

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//删除购物车
		String id = request.getParameter("CollectId");
		JsonResult result=null;
		
		CollectServieImpI deleteCollectServie = new CollectServieImpI();
	    int a  = deleteCollectServie.remove(id);
		try {
			if(a>0){				
				result = new JsonResult("删除成功",Constants.STATUS_SUCCESS);
			}else {				
				result=new JsonResult( "删除失败",Constants.STATUS_UNFOUND);
			}
		} catch (Exception e) {			
			result=new JsonResult("删除异常",Constants.STATUS_FAILURE);
		}
		
		JsonResultWriter.writer(response, result);
	}


}
